#include <iostream>

using namespace std;
int main() {
    int area[50][50][50]; //定义一个三维空间
    int q;  //定义切割次数
    int w,x,h;  //定义长宽高
    int x1,y1,z1,x2,y2,z2; //定义方块的对角坐标
    int count=0;
    cin>>w>>x>>h;
    cin>>q;
    //初始化三维空间，赋1
    for (int i = 1; i <=w ; ++i) {
        for (int j = 1; j <=x ; ++j) {
            for (int k = 1; k <=h ; ++k) {
                area[i][j][k]=1;
            }
        }
    }
    //切割,赋0
    while (q--){
        cin>>x1>>y1>>z1>>x2>>y2>>z2;
        for (int i = x1; i <=x2 ; ++i) {
            for (int j = y1; j <=y2 ; ++j) {
                for (int k = z1; k <=z2 ; ++k) {
                    area[i][j][k]=0;
                }
            }
        }
    }
    //扫描，找1，确定未切割的小方块
    for (int i = 1; i <=w ; ++i) {
        for (int j = 1; j <=x ; ++j) {
            for (int k = 1; k <=h ; ++k) {
                if (area[i][j][k]==1){
                    count++;
                }
            }
        }
    }
    cout<<count;
    return 0;
}
